package com.wct.springSecurity.common;

import com.wct.springSecurity.domain.SysUser;

import javax.servlet.http.HttpServletRequest;

/**
 * @author WEI (Email:changtan20000@163.com)
 * @description
 * @date 2020/1/17 22:20
 */
public class RequestHolder {
    private final static ThreadLocal<SysUser> userHolder = new ThreadLocal<>();
    private final static ThreadLocal<HttpServletRequest> requestHolder = new ThreadLocal<>();

    public static void add(SysUser sysUser) {
        userHolder.set(sysUser);
    }
    public static void add(HttpServletRequest request) {
        requestHolder.set(request);
    }

    public static SysUser getCurrentUser() {
        return userHolder.get();
    }
    public static HttpServletRequest getCurrentRequest() {
        return requestHolder.get();
    }

    public static void remove() {
        userHolder.remove();
        requestHolder.remove();
    }
}
